package com.cdu.practicaltraining.sys.mapper;

import com.cdu.practicaltraining.pojo.Dict;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface DictMapper {
    // 添加字典
    int addDict(Dict dict) throws Exception;

    // 查询字典
    Dict findDict(String dname) throws Exception;

    // 查询所有字典（分页功能）
    List<Dict> dicts() throws Exception;

    // 修改字典
    int updateDict(Dict dict) throws Exception;

    // 根据id查询字典
    Dict findById(int id) throws Exception;

    // 逻辑删除字典
    @Update("update t_dict set is_deleted = 1, version = version + 1 where id = #{id}")
    int deleteDict(long id) throws Exception;
}
